package com.ceres.system.controller;

import com.ceres.entity.Result;
import com.ceres.entity.StatusCode;
import com.ceres.system.pojo.Customer;
import com.ceres.system.service.SystemService;
import com.ceres.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system")
public class SystemController {

    @Autowired
    private SystemService systemService;

    /**
     * 通过农业组织id查询农业组织
     *
     * @param
     * @return
     */
    @GetMapping("/findCust")
    public Result findCust() {
        try {
            String username = "001";
            Customer customer = systemService.findCust(username);
            return new Result(true, StatusCode.OK, customer);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true, StatusCode.ERROR);
        }
    }

    @PutMapping("/changeTheme")
    public Result changeTheme(String theme) {
        try {
            String username = "derder";
            systemService.changeTheme(username, theme);
            return new Result(true, StatusCode.OK);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true, StatusCode.ERROR);
        }
    }
    @PutMapping("/updateLogo")
    public Result updateLogo(String updateLogo) {
        try {
            String username = "derder";
            systemService.updateLogo(username, updateLogo);
            return new Result(true, StatusCode.OK);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true, StatusCode.ERROR);
        }
    }
    @PutMapping("/updateProjectName")
    public Result updateProjectName(String ProjectName) {
        try {
            String username = "derder";
            systemService.updateProjectName(username, ProjectName);
            return new Result(true, StatusCode.OK);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(true, StatusCode.ERROR);
        }
    }


}
